<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/views/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/views/include/nocachehead.jsp"%>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/attraction.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/validator/discoveryForm.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
<script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/map.js"></script>
</head>

<body>
	<%@ include file="/views/include/statusbar.jsp"%>
	<br>
	<br>
	<br>

	<img src="${pageContext.request.contextPath}/image/${attractionInfo.portrait }">
	<a href="${pageContext.request.contextPath}/attraction/upPortrait/${attractionInfo.id }.html">更换景点头像</a>

	<c:out value="${requestScope.errMsg}" escapeXml="false" />
	
	<form id="discoveryForm" action="${pageContext.request.contextPath}/attraction/edit/${attractionInfo.id }.html" method="post">
		<p>
			<label>地点名称：</label>
			<input name="id" type="hidden" value="${attractionInfo.id}" />
			<input id="adminId"	name="adminId" type="hidden" value="${attractionInfo.adminId}" />
			<input id="name" name="name" value="${attractionInfo.name}" onBlur="checkAttractionExist(this.value);" />
			<label id="nameExist" for="name" class="error" style="display:none;">已经存在该名字景点，请另外选择名称</label>
		</p>		
		<p>
			<label> 分类：</label>
			<select id="category" name="category">
				<option value="ATTRACTION" <c:if test="${attractionInfo.category eq 'ATTRACTION'}">s</c:if>>景点</option>
				<option value="OTHER" <c:if test="${attractionInfo.category eq 'OTHER'}"></c:if>>其他</option>
			</select>
		</p>
		<p>
			<label>地点：</label>
			<select id="country" name="country" onchange="getProvinces('','')">
				<option value="">请选择</option>
			</select>
			<select id="province" name="province" onchange="getCities('')">
				<option value="">请选择</option>
			</select>
			<select id="city" name="city">
				<option value="">请选择</option>
			</select>
		</p>	
		<p>
			<label> 具体地址：</label>
			<input type="text" name="detailAddress" id="detailAddress" value="${attractionInfo.detailAddress }" size="30" />
		</p>
		<div id="searchMsg"></div>
		<div>
			<label>地图位置：</label>
			<span>在地图中找不到?</span>
			<input type="text" id="suggest" />
			<button id="serchLocation">搜搜看</button>
			<div id="mapContainer" style="height: 400px; width: 700px;"></div>
			<input id="latitude" name="latitude" type="hidden" value="${attractionInfo.latitude}"/>
			<input id="longitude" name="longitude" type="hidden" value="${attractionInfo.longitude}"/>
		</div>
		<p style="width:200px">
			<label>景点简介：</label>
			<textarea rows="5" cols="30" id="introduction" name="introduction">${attractionInfo.introduction}</textarea>
		</p>
		<p>
			<input type="hidden" name="submitToken" value='<skyline:sessionAttribute key="SESSION_SUBMIT_TOKEN"/>' />
			<input type="submit" name="submit" value="保存修改" />
		</p>
	</form>

	<script type="text/javascript">
	$(document).ready(function() {
		getCountries('${attractionInfo.country}', '${attractionInfo.province}', '${attractionInfo.city}');
		var oldPoint = new BMap.Point('${attractionInfo.longitude}','${attractionInfo.latitude}'); 
		recenterMap(oldPoint);
		oldmark = createDraggableMarker(oldPoint, function(evnt){
			$("#longitude").val(evnt.point.lng);
			$("#latitude").val(evnt.point.lat);
			processAddress(evnt.point,'city','detailAddress');
			popAddressInfo(oldmark, evnt.point, 'name');
		});
		addMarkerOnMap(map, oldmark);
		popAddressInfo(oldmark, oldPoint, 'name');
	});
	</script>
</body>
</html>